/**
 * 
 */
package util;
import weka.core.Instances;
import weka.filters.Filter;
import weka.filters.unsupervised.attribute.Remove;

import java.io.BufferedReader;
import java.io.FileReader;

public class RemoveAtributo {
  /**
   * takes an ARFF file as first argument, the number of indices to remove
   * as second and thirdly whether to invert or not (true/false).
   * Dumps the generated data to stdout.
   */
  public static Instances remove(String arquivo, String numIndices, boolean inverter) throws Exception {
    Instances       inst;
    Instances       instNew;
    Remove          remove;

    inst   = new Instances(new BufferedReader(new FileReader(arquivo)));
    remove = new Remove();
    remove.setAttributeIndices(numIndices);
    remove.setInvertSelection(inverter);
    remove.setInputFormat(inst);
    instNew = Filter.useFilter(inst, remove);
    return instNew;
  }
}